#include "hash_util.h"
#include <stdio.h>
#include <immintrin.h>
#include <assert.h>

#define bitScan(x)  __builtin_ffs(x)

int main() {

    char arr1[16] = "1111111111111110"; 

    __m128i arr1_16B = _mm_load_si128((const __m128i*)arr1);
    __m128i arr2_16B = _mm_set1_epi8('1');

    __m128i cmp_res = _mm_cmpeq_epi8(arr1_16B, arr2_16B);
    int mask = _mm_movemask_epi8(cmp_res);

    while (mask) {
        int jj = bitScan(mask)-1;  
        // jj 表示的是参与比较的arr1和arr2第一次出现相同的位置
        printf("jj = %d\n", jj);

        assert(arr1[jj] == '1');
        mask &= ~(0x1<<jj);  // remove this bit
        //printf("mask = %d\n\n", mask);
    }
    return 0;
}